<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
JsWs Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="global.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>JsWs</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>global.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'global.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="ExBase.html">ExBase</a></b></td>
    <td>This class forms the basis for all other exceptions.</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="ExParamError.html">ExParamError</a></b></td>
    <td>Exception class for parameter errors
 </td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

	<a name="method_summary"><!-- --></a>
	<table border="1" cellpadding="3" cellspacing="0" width="100%">
		<tr bgcolor="#CCCCFF" class="TableHeadingColor">
			<td colspan=2>
				<font size="+2">
					<b>Method Summary</b>
				</font>
			</td>
		</tr>
	
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;void</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!SubClass">SubClass</a></b>(&lt;Class&gt; base, &lt;Class&gt; sub)
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 Makes one "class" inherit from another while maintaining constructor chain
 and not breaking instanceof usage
		      </td>
		   </tr>
		
	
	</table>
    <p>

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* ***** BEGIN LICENSE BLOCK *****
 *   Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is JsWs.
 *
 * The Initial Developer of the Original Code is
 * Chris Winberry.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */</span>

<span class="comment">/*** FILES &amp; LOCATIONS ***/</span>
var JSWS_ROOT				= <span class="literal">"/jsws"</span>;					<span class="comment">// Root folder for all JsWs files</span>
var JSWS_DOCROOT			= <span class="literal">"/htdocs"</span>;	<span class="comment">// Folder that contains all served content</span>
var JSWS_DB_ROOT			= <span class="literal">"/data"</span>;		<span class="comment">// Folder where SQLite/MozStorage DB files are kept</span>
var JSWS_SCRIPT_FILEEXT		= <span class="literal">"jss"</span>;					<span class="comment">// File extension for scripts that JsWs will execute</span>
var JSWS_DB_FILEEXT			= <span class="literal">"storage"</span>;				<span class="comment">// File extension for SQLite/MozStorage DB files</span>

<span class="comment">/*** PREFERENCES ***/</span>
var JSWS_PREF_ROOT			= <span class="literal">"extensions.jsws."</span>;			<span class="comment">// Root of all preference settings</span>
var JSWS_PREF_AUTOSTART		= JSWS_PREF_ROOT + <span class="literal">"autostart"</span>;	<span class="comment">// Flag - should JsWs start automatically</span>
var JSWS_PREF_PORT			= JSWS_PREF_ROOT + <span class="literal">"port"</span>;		<span class="comment">// TCP port JsWs will listen on</span>
var JSWS_PREF_LOCALONLY		= JSWS_PREF_ROOT + <span class="literal">"localOnly"</span>;	<span class="comment">// Flag - should JsWs only accept loopback connections</span>
var JSWS_PREF_THREADED		= JSWS_PREF_ROOT + <span class="literal">"threaded"</span>;	<span class="comment">// Flag - should JsWs run in a separate thread</span>

<span class="comment">/*** MODULES ***/</span>
var JSWS_PREF_MODULES_ROOT		= JSWS_PREF_ROOT + <span class="literal">"modules."</span>;	<span class="comment">// Root of all module registrations</span>
var JSWS_MODULES_ROOTKEY		= <span class="literal">"root"</span>;						<span class="comment">// Reserved module name for "/"</span>
var JSWS_MODULES_IDKEY			= <span class="literal">"id"</span>;							<span class="comment">// Key for modules' extension ID</span>
var JSWS_MODULES_NAMEKEY		= <span class="literal">"name"</span>;						<span class="comment">// Key for modules' display name</span>
var JSWS_MODULES_EXTENSIONPATHKEY	= <span class="literal">"extPath"</span>;				<span class="comment">// Key for modules' root folder</span>
var JSWS_MODULES_CONTENTPATHKEY	= <span class="literal">"contentPath"</span>;				<span class="comment">// Key for modules' location of servable content</span>
var JSWS_MODULES_VIRTUALPATHKEY	= <span class="literal">"virtualPath"</span>;				<span class="comment">// Key for modules' mapping to a JsWs path</span>
var JSWS_MODULES_STARTPAGEKEY	= <span class="literal">"startPage"</span>;					<span class="comment">// Key for modules' default start page</span>
var JSWS_MODULES_HANDLERKEY		= <span class="literal">"handler"</span>;					<span class="comment">// Key for modules' page handler</span>
var JSWS_MODULES_INITPAGEKEY	= <span class="literal">"initPage"</span>;					<span class="comment">// Key for modules' initialization page</span>
var JSWS_MODULES_DESCRIPTIONKEY	= <span class="literal">"description"</span>;				<span class="comment">// Key for modules' description</span>

<span class="reserved">if</span> (!Cc)
	var Cc = Components.classes;
<span class="reserved">if</span> (!Ccon)
	var Ccon = Components.Constructor;
<span class="reserved">if</span> (!Ci)
	var Ci = Components.interfaces;

var nsLocalFile = Ccon(<span class="literal">"@mozilla.org/file/local;1"</span>, <span class="literal">"nsILocalFile"</span>, <span class="literal">"initWithPath"</span>);


<span class="comment">/**
 * Makes one "class" inherit from another while maintaining constructor chain
 * and not breaking instanceof usage
 * <span class="attrib">@param</span> {Class} base constructor to inherited from
 * <span class="attrib">@param</span> {Class} sub constructor to subclass from base
 */</span>
<span class="reserved">function</span> SubClass (base, sub) {
	<span class="reserved">function</span> proxyObject () { }
	proxyObject.<span class="reserved">prototype</span> = base.<span class="reserved">prototype</span>;

	var proxy = new proxyObject();
	proxy.constructor = sub;
	sub.baseConstructor = base;
	sub.<span class="reserved">prototype</span> = proxy;
}

<span class="comment">/**
 * Base class for exceptions to inherit from
 * <span class="attrib">@class</span> This class forms the basis for all other exceptions. It provides
 *  consistent display formatting and wrapping of earlier/inner exceptions.
 *  Inner exceptions are a convenient way to establish a lazy call stack for
 *  debugging and error reporting.
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@param</span> {String} msg Description of exception
 * <span class="attrib">@param</span> {Number} code (optional) Error code
 * <span class="attrib">@param</span> {Exception} ex (optional) An earlier exception to wrap
 * <span class="attrib">@param</span> {Arguments} args (optional) Arguments array of a functions
 */</span>
<span class="reserved">function</span> ExBase (msg, code, ex, args) {
	<span class="comment">/**
	 * Description of the exception
	 * <span class="attrib">@type</span> String
	 */</span>
	<span class="reserved">this</span>.message = <span class="literal">""</span>;
	<span class="comment">/**
	 * Exception error code
	 * <span class="attrib">@type</span> Number
	 */</span>
	<span class="reserved">this</span>.code = 0;
	<span class="comment">/**
	 * Earlier exception wrapped by the current exception
	 * <span class="attrib">@type</span> Exception
	 */</span>
	<span class="reserved">this</span>.originalEx = null;
	<span class="comment">/**
	 * Arguments passed to code throwing the exception
	 * <span class="attrib">@type</span> Arguments
	 */</span>
	<span class="reserved">this</span>.args = null;

	<span class="reserved">this</span>.init(msg, code, ex, args);
}


<span class="comment">/** <span class="attrib">@private</span> */</span>
ExBase.<span class="reserved">prototype</span>.init = <span class="reserved">function</span> (msg, code, ex, args) {
	<span class="reserved">if</span> (code != null)
		<span class="reserved">this</span>.code = code;
	<span class="reserved">this</span>.message = msg;
	<span class="reserved">if</span> (ex != null)
		<span class="reserved">this</span>.originalEx = ex;
	<span class="reserved">if</span> (args != null)
		<span class="reserved">this</span>.args = args;
}


<span class="comment">/**
 * <span class="attrib">@returns</span> Name of the exception type
 * <span class="attrib">@type</span> String
 */</span>
ExBase.<span class="reserved">prototype</span>.name = <span class="reserved">function</span> () {
	<span class="reserved">return</span> /(\w+)\(/.exec(<span class="reserved">this</span>.constructor.toString())[1];
}


<span class="comment">/**
 * Serializer
 * <span class="attrib">@type</span> String
 */</span>
ExBase.<span class="reserved">prototype</span>.toString = <span class="reserved">function</span> () {
	<span class="reserved">return</span>(<span class="literal">"{{"</span> + <span class="reserved">this</span>.name() + <span class="literal">"}}"</span>
		+ <span class="literal">" [ErrNum: "</span> + <span class="reserved">this</span>.code + <span class="literal">"] :"</span>
		+ <span class="literal">" "</span> + <span class="reserved">this</span>.message
		+ ((<span class="reserved">this</span>.args != null) ? <span class="reserved">this</span>.formatArgs(<span class="reserved">this</span>.args) : <span class="literal">""</span>)
		+ ((<span class="reserved">this</span>.originalEx != null) ? <span class="literal">"\n"</span> + 
			((<span class="reserved">this</span>.originalEx instanceof ExBase) ? <span class="reserved">this</span>.originalEx : <span class="reserved">this</span>.formatExternalEx(<span class="reserved">this</span>.originalEx))
			:
			<span class="literal">""</span>)
		);
}


<span class="comment">/** <span class="attrib">@private</span> */</span>
ExBase.<span class="reserved">prototype</span>.formatArgs = <span class="reserved">function</span> (args) {
	var matches = args.callee.toString().match(/^\s*<span class="reserved">function</span>\s+([^\(\)]+)\s*\(([^\(\)]*)\) \{/i);
	var funcName = matches[1];
	var params = matches[2].split(/,\s*/);
	
	var output = <span class="literal">"\n(Function:\n"</span>;
	output += <span class="literal">"  "</span> + funcName + <span class="literal">" ("</span> + params.join(<span class="literal">', '</span>) + <span class="literal">")\n"</span>;
	output += <span class="literal">"    # of args: "</span> + args.length + <span class="literal">"\n"</span>;
	<span class="reserved">for</span> (var i = 0; i &lt; args.length; i++) {
		output += <span class="literal">"    "</span> + (params[i] ? params[i] : <span class="literal">"???"</span>) + <span class="literal">": ("</span> + typeof args[i] + <span class="literal">") "</span> + args[i] + <span class="literal">"\n"</span>;
	}
	output += <span class="literal">")\n"</span>;
		
	<span class="reserved">return</span>(output);
}


<span class="comment">/** <span class="attrib">@private</span> */</span>
ExBase.<span class="reserved">prototype</span>.formatExternalEx = <span class="reserved">function</span> (ex) {
	<span class="reserved">return</span>(
		<span class="literal">"{{"</span> + ex.name + <span class="literal">"}}\n"</span>
		+ <span class="literal">"   Msg: "</span> + ex.message + <span class="literal">"\n"</span>
		+ <span class="literal">"   File: "</span> + ex.fileName + <span class="literal">"(Line:"</span> + ex.lineNumber + <span class="literal">")\n"</span>
		+ <span class="literal">"   Stack: "</span> + ex.stack
		);
}

<span class="comment">/**
 * <span class="attrib">@class</span> Exception class for parameter errors
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@base</span> ExBase
 * <span class="attrib">@param</span> {String} msg Description of exception
 * <span class="attrib">@param</span> {Number} code (optional) Error code
 * <span class="attrib">@param</span> {Exception} ex (optional) An earlier exception to wrap
 * <span class="attrib">@param</span> {Arguments} args (optional) Arguments array of a functions
 */</span>
<span class="reserved">function</span> ExParamError (msg, code, ex, args) { ExParamError.baseConstructor.call(<span class="reserved">this</span>, msg, code, ex, args); }
SubClass(ExBase, ExParamError);

</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>JsWs</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Nov  8 22:50:16 2007</div>
</body>
</html>
